<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>盛筑OA</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../static/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../static/kaige/css/login.css?v=20220612" media="all">
</head>

<body>
    <div id="container" class="container">
        <div id="particles-js" class="particles-js"></div>
    </div>
    <div class="kaige-login">
        <!-- <div class="tiyanpcode">
            <div class="tiyanpimg"></div>
            <div class="tiyantxt">扫码联系客服获取体验账号</div>
        </div> -->
        <div class="kaige-login-main">
            <div class="kaige-login-header">
                <h2>盛筑OA</h2>
                <p>v1.0.0</p>
            </div>
            <div class="kaige-login-box kaige-login-body layui-form">
                <div class="layui-form-item">
                    <label class="kaige-login-icon layui-icon layui-icon-username"></label>
                    <input type="text" name="username" lay-verify="required" placeholder="账号" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="kaige-login-icon layui-icon layui-icon-password"></label>
                    <input type="password" name="password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item ndis" id="captcha_div">
                    <div class="layui-row">
                        <div class="layui-col-xs6">
                            <label class="kaige-login-icon layui-icon layui-icon-vercode"></label>
                            <input type="text" name="captcha" id="captcha_ipt" placeholder="验证码" class="layui-input">
                        </div>
                        <div class="layui-col-xs6">
                            <div style="margin-left:3px;">
                                <img src="" id="captcha_img" onclick="setCaptcha()" title="点击更换验证码" alt="captcha"
                                    style="width:100%;height:38px; cursor:pointer;" />
                                <input type="hidden" id="captcha_key" name="key">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="mlogin" id="mlogin"
                        style="background-color: #0176c0;">登 录</button>
                </div>
            </div>
        </div>
        <div class="layui-trans kaige-login-footer">
            <span id="copytxt">&copy;2022 泉州市盛筑信息科技有限公司 版权所有</span>
            <a href="http://beian.miit.gov.cn/" target="_blank" id="icptxt">ICP备案证书号:闽ICP备2022000750号</a>
            <span>
                <script src="https://js.users.51.la/21407291.js"></script>
            </span>
        </div>
    </div>
    <script src="../static/lib/jquery/jquery.min.js"></script>
    <script src="../static/kaige/js/qs.js"></script>
    <script src="../static/kaige/js/cry/md5.js"></script>
    <script src="../static/kaige/js/cry/sha1.js"></script>
    <script src="../static/kaige/js/szconfig.js"></script>
    <script src="../static/kaige/js/szoa.js"></script>
    <script src="../static/lib/layui/layui.js"></script>
    <script src="../static/kaige/js/particles.js"></script>
    <script>
        if (window != top) {
            top.location.href = window.location.href;
        }
        layui.use(['layer', 'form'], function () {
            var $ = layui.$, layer = layui.layer, form = layui.form;

            var device = layui.device();
            if (device.mobile) {
                window.location.href = '/mp/';
            }

            if (szoa.getToken()) {
                layer.msg('loading...', { time: 200 }, function () {
                    window.location.href = szoa.client.path + '/index.html';
                });
            }
            //取数据
            var data = [];
            $.ajax({
                url: '/login/getinfo',
                async: true,
                success: function (res) {
                    if (res.status) {
                        var d = res.data;
                        if (d.title) document.title = d.title;
                        if (d.site_name && d.app_version) {
                            $('.kaige-login-header').html('<h2>' + d.site_name + '</h2><p>' + d.app_version + '</p>');
                        }
                        if (d.miitbeian && d.site_copy) {
                            $("#copytxt").html(d.site_copy);
                            $("#icptxt").html('ICP备案证书号:' + d.miitbeian);
                        }
                    }
                }
            });

            // 获取验证码
            function getCaptcha() {
                $.ajax({
                    url: '/captcha',
                    async: true,
                    success: function (res) {
                        if (res.status) {
                            $('#captcha_img').attr('src', res.data.img);
                            $('#captcha_key').val(res.data.key);
                        }
                    }
                });
            };
            getCaptcha();
            form.render();
            function keyDownSearch(e) {
                // 兼容
                var theEvent = e || window.event;
                var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                if (code == 13) {
                    $('#mlogin').click();
                    return false;
                }
                return true;
            }
            //提交
            form.on('submit(mlogin)', function (data) {
                szoa.post('/login/index', data.field, function (data) {
                    layer.msg(data.msg);
                    if (data.status) {
                        szoa.setToken(data.data.token);
                        szoa.setCache('User-Info', JSON.stringify(data.data.userinfo), szoa.client.expires);
                        setTimeout(function () {
                            window.location.href = szoa.client.path + '/index.html';
                        }, 1500);
                    } else {
                        $("#mlogin").removeClass('layui-btn-disabled');
                        if (data.data == 2109 || data.data == 2110 || data.data == 1004) {
                            $('#captcha_div').show();
                        }
                        setCaptcha();
                    }
                });
                $("#mlogin").addClass('layui-btn-disabled');
                return false;
            });

            //更改验证码图片
            window.setCaptcha = function () {
                $('#captcha_ipt').val("");
                getCaptcha();
            };

            particlesJS('particles-js');
            document.onkeydown=keyDownSearch;
        });

    </script>
</body>

</html>